package io.shallwe._admin.permission;

import com.jfinal.aop.Inject;
import com.jfinal.kit.Ret;

import io.shallwe.common.controller.BaseController;
import io.shallwe.common.model.Permission;

/**
 * 权限管理
 */
public class PermissionAdminController extends BaseController {

	@Inject
	PermissionAdminService srv;

	public void index() {
		render("permission.html");
	}

	public void list() {
		Integer offset = getParaToInt("offset",1);
        Integer pageSize = getParaToInt("pageSize",10);
		renderJson(srv.paginate(offset,pageSize));
	}
	public void sync() {
		Ret ret = srv.sync();
		renderJson(ret);
	}

	public void edit() {
		Permission permission = srv.findById(getPara("id"));
		setAttr("permission", permission);
		render("edit.html");
	}

	public void update() {
		Ret ret = srv.update(getBean(Permission.class));
		renderJson(ret);
	}

	public void delete() {
		Ret ret = srv.delete(getPara("id"));
		renderJson(ret);
	}
}